package com.deer.wms.base.system.web.take;

import com.deer.wms.base.system.model.bill.BillOutMasterCriteria;
import com.deer.wms.base.system.model.bill.BillOutMasterDto;
import com.deer.wms.base.system.model.take.AreaTaskStockDaily;
import com.deer.wms.base.system.model.take.TakeStockDaily;
import com.deer.wms.base.system.service.take.TakeStockDailyService;
import com.deer.wms.base.system.util.DateUtil;
import com.deer.wms.common.core.controller.BaseController;
import com.deer.wms.common.core.domain.AjaxResult;
import com.deer.wms.common.core.page.TableDataInfo;
import com.deer.wms.common.utils.poi.ExcelUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("takeStockDaily")
public class TakeStockDailyController extends BaseController {
    @Autowired
    private TakeStockDailyService takeStockDailyService;

    private String prefix = "take";

    /**
     *跳转显示页面
     * @return
     */
    @GetMapping("/page")
    public String takeStockDaily()
    {
        return prefix + "/takeStockDaily";
    }
    @GetMapping("/areaPage")
    public String areaTakeStockDaily()
    {
        return prefix + "/areaTakeStockDaily";
    }

    @PostMapping("/areaFindList")
    @ResponseBody
    public TableDataInfo areaFindList(TakeStockDaily takeStockDaily){
        startPage();
        List<AreaTaskStockDaily> areaBoxItemQuantity = takeStockDailyService.getAreaBoxItemQuantity(takeStockDaily);
        return getDataTable(areaBoxItemQuantity);
    }

    @PostMapping("/findList")
    @ResponseBody
    public TableDataInfo findList(TakeStockDaily takeStockDaily){
        startPage();
        List<TakeStockDaily> list = takeStockDailyService.getAllQuantity(takeStockDaily);
        return getDataTable(list);
    }

    /**
     * 导出出库单列表
     */
    @RequiresPermissions("takeStockDaily:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TakeStockDaily takeStockDaily) {
        List<TakeStockDaily> list = takeStockDailyService.getAllQuantity(takeStockDaily);
        ExcelUtil<TakeStockDaily> util = new ExcelUtil<TakeStockDaily>(TakeStockDaily.class);
        return util.exportExcel(list, "立库盘点日报");
    }
    /**
     * 导出出库单列表
     */
    @RequiresPermissions("takeStockDaily:export")
    @PostMapping("/areaExport")
    @ResponseBody
    public AjaxResult areaExport(TakeStockDaily takeStockDaily) {
        List<AreaTaskStockDaily> areaBoxItemQuantity = takeStockDailyService.getAreaBoxItemQuantity(takeStockDaily);
        ExcelUtil<AreaTaskStockDaily> util = new ExcelUtil<AreaTaskStockDaily>(AreaTaskStockDaily.class);
        return util.exportExcel(areaBoxItemQuantity, "暂存区盘点日报");
    }

    @PostMapping("/getAllQuantity")
    @ResponseBody
    public List<TakeStockDaily> getAllQuantity(TakeStockDaily takeStockDaily){

        List<TakeStockDaily> list = takeStockDailyService.getAllQuantity(takeStockDaily);
       return list;
    }


}
